package gui;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

import logic.Constantes;

import com.gif4j.*;

public class BlockGenerator {
	
	public static final int IZQ = 0;
	public static final int TOP = 1;
	public static final int DER = 2;
	public static final int BOT = 3;
	
	
	BlockGenerator(){
		
	}
	
	public static Block createinicio(){
		Block label = new Block();
		
		Image image = Toolkit.getDefaultToolkit().getImage("GIFS/Inicio.gif");
		label.addImage(image, 0);
		return label;
	}
	
	public static Block createVar(){
		Block label = new Block();		
		ImageIcon img = new ImageIcon("GIFS/Varible.png");
		label.setIcon(img);
		return label;
	}
	public static void rotateIcon() {
		ImageIcon icon = new ImageIcon("GIFS/Untitled-4.gif");
		int w = icon.getIconWidth();
		int h = icon.getIconHeight();

		BufferedImage image = new BufferedImage(h, w, BufferedImage.TYPE_INT_RGB);

		Graphics2D g2d = image.createGraphics();
		double x = (h- w)/2.0;
		double y = (w-h)/2.0;

		AffineTransform at = AffineTransform.getTranslateInstance(x, y);
		at.rotate(Math.toRadians(270), w/2.0, h/2.0);

		g2d.drawImage(icon.getImage(),at,icon.getImageObserver());
		try{
			ImageIO.write(image,"png",new File("GIFS/Untitled-10.gif"));
        } catch (Exception FileOutputException){}		
	}
	
	public static Block createAddVar(){
		Block label = new Block();		
		ImageIcon img = new ImageIcon("src/gui/add.gif");
		label.setIcon(img);
		return label;
	}
	
	public static Block createConexion( int Origen , int Destino ){
		Block label = new Block();
		ImageIcon img = new ImageIcon( Constantes.IMAGES[Origen][Destino] ) ;
		label.setIcon(img);
		return label;
	}
	
	public void createDoubleDivisor( int Origen,  int Destino1 , int Destino2){
		
	}
	
	public void createTripleDivisor( int Origen , int Destino1 , int Destino2){
		
	}
	
	public void createCondicional( int Origen , int DestinoYes , int DestinoNo ){
		
	}

}
